namespace SimpleWebServices.Net
{
    using System;
    using System.IO;
    using System.Net.Mime;

    public sealed class TextPlain : IHttpContent
    {
        public TextPlain()
        {
        }

        public TextPlain(string value)
        {
            this.Value = value;
        }

        public ContentType Type
        {
            get
            {
                return new ContentType("text/plain");
            }
        }

        public string Value
        {
            get;
            set;
        }

        public void Write(Stream stream)
        {
            if (null == stream)
            {
                throw new ArgumentNullException("stream");
            }

            using (StreamWriter writer = new StreamWriter(stream))
            {
                writer.Write(this.Value);
            }
        }
    }
}